package com.campuscarbooking.api.controller;

import com.campuscarbooking.api.dto.ApiResponse;
import com.campuscarbooking.api.dto.UserDTO;
import com.campuscarbooking.api.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户接口")
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @ApiOperation(value = "获取用户信息", notes = "获取当前登录用户的信息")
    @GetMapping("/profile")
    public ApiResponse<UserDTO> getUserProfile() {
        UserDTO user = userService.getCurrentUserDTO();
        return ApiResponse.success(user);
    }

    @ApiOperation(value = "验证Token", notes = "验证当前token是否有效")
    @GetMapping("/validate")
    public ApiResponse<Void> validateToken() {
        // 如果能通过认证访问到这个接口，说明token有效
        return ApiResponse.success(null);
    }
} 